<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$this->model('model')->up_cang();
	$sharelink='jy_jicai/index//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$this->setting['share_title']?:'积分理财-在线抢购',
			'desc'=>$this->setting['share_desc']?:'积分理财，多倍获利！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>ATTACHMENT_URL.$return['pluginset']['logo']
	);
	set_html('title','积分理财');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['keyword']){
		$params['title like']='%;'.$_RQ['keyword'].';%';
	}
    $orderby='createtime desc';
	$total='';
	$list=pdo_getslice('jy_jicai_cang',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		foreach($list as &$item){
			$item=$this->model('model')->up_canginfo($item);
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['salenum']=pdo_count('jy_jicai_canlog',array('uniacid'=>$_SESSION['uniacid'],'cangid'=>$item['id']),'id');
			$item['statustitle']=$this->cang_status[$item['status']];
			$item['yao']=pdo_get('jy_jicai_yao',array('cangid'=>$item['id'],'status'=>1,'uniacid'=>$_SESSION['uniacid']));
			$item['isfee']=pdo_getsum('jy_jicai_canlog',array('yaoid'=>$item['yao']['id'],'cangid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']),'jifen');
			$item['israte']=$item['isfee']?$item['isfee']/$item['yao']['alljifee']:0;
		}
	}
	$return['list']=$list;
	exi($return);
}
?>